using DevExpress.XtraEditors;
using System;
using System.ComponentModel;
using System.Drawing;
namespace Common.UI
{
	public class XucTextEdit : TextEdit
	{
		private IContainer components = null;
		private string _defaultText;
		public string DefaultText
		{
			get
			{
				return this._defaultText;
			}
			set
			{
				this._defaultText = value;
				base.Text = this._defaultText;
				base.Properties.NullText = this._defaultText;
				base.Properties.NullValuePrompt = this._defaultText;
			}
		}
		public sealed override string Text
		{
			get
			{
				return (base.Text == this._defaultText) ? "" : base.Text;
			}
			set
			{
				if (value != this._defaultText)
				{
					base.Text = value;
				}
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
		}
		public XucTextEdit()
		{
			this.InitializeComponent();
			base.ForeColor = Color.DarkGray;
			base.Text = this._defaultText;
			base.ForeColor = Color.DarkGray;
		}
		protected override void OnTextChanged(EventArgs e)
		{
			if (base.Text.Length == 0)
			{
				base.Text = this._defaultText;
				base.ForeColor = Color.DarkGray;
			}
			else
			{
				base.ForeColor = Color.Black;
			}
		}
		protected override void OnLeave(EventArgs e)
		{
			if (base.Text.Length == 0)
			{
				base.Text = this._defaultText;
				base.ForeColor = Color.DarkGray;
			}
		}
		protected override void OnClick(EventArgs e)
		{
			if (base.Text == this._defaultText)
			{
				base.Text = "";
			}
			base.ForeColor = Color.Black;
		}
	}
}
